home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
basicaid.arc
/
BASICAID.DOC
next >
Wrap
Text File
|
1985-08-26
|
12KB
|
279 lines
BASICAID
THE BASIC PROGRAMMERS FRIEND
BY
JAMES P. MORGAN
1749 AMERICANA BLVD APT 23-G
ORLANDO FLA. 32809
PH 305-826-7297
HAVE YOU EVER ACQUIRED A BASIC PROGRAM FROM A FRIEND AND SPENT ALOT OF
TIME JUST TRYING TO UNTANGLE THE PROGRAM LOGIC AND STATEMENTS, OF COURSE YOU
HAVE.
SINCE EACH PERSONS PROGRAMMING STYLE IS DIFFERENT , SUCH AS SPACING, INDEN-
TATION AND SUCH, YOU COULD USE YOUR TIME BETTER IF ALL PROGRAMS WERE ABOUT
THE SAME STYLE.
ARE YOU A OPTIMIZATION AND SPEED NUT , AS I AM, ESPECIALLY WHEN RUNNING
A PROGRAM UNDER THE INTERPRETER. I DONT'T LIKE TO WAIT A SECOND LONGER THAN
NECESSARY. OF COURSE BY NOW I USE THE BASIC COMPILER AS MUCH AS POSSIBLE,
SINCE I WOULD RATHER WAIT 2 MINUTES THAN HAVE TO WAIT 20 MINUTES TO SEE
THE RESULTS OF MY SWEAT , BLOOD AND LOST SLEEP.
I HAVE SEEN SEVERAL PACKAGES , NOT ALL WITH THE SAME FUNCTIONS OR
RANGE SELLING FROM 20 TO 80 DOLLARS. WELL THIS IS 6 MONTHS OF WORK
, TO YOU FOR FREE. HOW ABOUT THE PRICE TAG ON THIS.
YOU ASK WHAT WILL THIS PROGRAM DO FOR ME, PAY MY TAXES MAYBE. WELL
NO, IT WON'T PAY YOUR TAXES BUT IT SHOULD MAKE YOUR LIFE A LITTLE EASIER.
AS A BASIC OVERVIEW THE PROGRAM WILL, COMPRESS A BASIC PROGRAM AND REMOVE
REMARKS, EXPAND A PROGRAM BY THAT I MEAN IT WILL SEPARATE MULTIPLE STATEMENTS
PER BASIC LINE INTO ONE OR MORE STATEMENTS, GENEREATE CROSS REFERENCES ON
PROGRAM VARIABLES AND BASIC RESERVED WORDS, AND PROBABLY THE MOST IMPORTANT
WILL GENERATE A CROSS REFERENCE SHOWING ALL REFERENCES TO A SPECIFIC LINE NUMBER,
THAT WERE REFERENCED BY A GOTO,GOSUB,ELSE,THEN,ERL,RESTORE OR RESUME STATEMENT.
YOU CAN THEN FIND ALL VARIABLES, AREAS OF CODE AND SUCH THAT ARE NOT
REFERENCED (AND REMOVE FOR STORAGE SAVINGS) AS WELL AS AN OVERVIEW OF
PROGRAM FLOW TO FIND OUT HOW THE PROGRAM GOT TO A SPECIFIC LINE NUMBER.
EACH FUNCTIONAL OPTION OF THE PROGRAM IS DISCUSSED BELOW:
1). EXPAND A BASIC PROGRAM
----------------------
WILL EXPAND A COMPRESSED PROGRAM, ONE THAT HAS MULTIPLE
BASIC STATEMENTS PER LINE, SEPARATED BY A ":" INTO ONE OR
MORE UNIQUELY NUMBERED BASIC LINES WITH ONE OR MORE STATEMENTS
PER LINE.
DURING THE EXPANDING SOME TEXT COMPRESSION WILL BE DONE,
TO REMOVE EXTRANEOUS SPACES AND SUCH.
ALSO AN EXPANDED LISTING CAN BE REQUESTED, THAT WILL BE PRINTED
DURING THE EXPANSION.
AN EXPANDED, OUTPUT DISK FILE, CALLED "TEMPFILE.BAS" WILL
BE CREATED ALSO. RENAME THE "TEMPFILE.BAS" IF YOU WANT TO SAVE
IT AS THE NEW VERSION OF YOUR PROGRAM.
NOTE THAT THE INPUT BASIC PROGRAM BEING EXPANDED MUST BE
SUFFICIENTLY SEQUENCED TO ALLOW THE INSERTION OF NEW LINES
OR THE PROGAM WILL END WITH SUCH A MESSAGE. FOR EXAMPLE IF
THERE ARE 7 BASIC STATEMENTS ON A LINE, SEPARATED BY ":",
THEN IF THE ORIGINAL PROGRAM WAS NUMBER BY 5'S THE PROGRAM
WILL SEPARATE THE LINE INTO 6 MORE BASIC LINES EACH WITH A
LINE NUMBER 1 GREATER THAN THE PREVIOUS LINE NUMBER.
2). COMPRESS A BASIC PROGRAM
------------------------
WILL COMPRESS TEXT (REMOVE EXTRANEOUS SPACES AND ":" AND SUCH)
AS WELL AS COMBINE SEPARATE BASIC LINES INTO SINGLE LINES WITH
AS MANY LOGICAL STATEMENTS PER LINE AS POSSIBLE.
BY LOGICAL I MEAN THAT ANY "REMARK" OR "IF" OR "DATA" STATEMENTS
WILL NOT HAVE LINES ADDED TO THEM.
ALSO ANY LINE REFERENCED BY A LOGIC BRANCH (GOTO,GOSUB..ECT) WILL
NOT BE APPENDED TO ANY OTHER LINE.
YOU MAY REQUEST A LISTING OF THE COMPRESSED PROGRAM BE PRODUCED
DURING THE COMPRESSION RUN, BUT WILL SLOW THE PROGRAM DOWN, UNLESS
YOU HAVE A SPOOLER.
AN COMPRESSED PROGRAM , DISK FILE, NAMED "TEMPCOMP.BAS" IS
CREATED. DON'T FORGET TO RENAME "TEMPCOMP.BAS" IF YOU WANT IT
TO BE YOUR NEW WORKING VERSION.
3). DATANAME AND RESERVED WORD CROSS REFERENCE
------------------------------------------
WILL PRINT A CROSS REFERENCE OF BASIC RESERVED WORDS (SUCH AS
GOTO,PRINT,CALL..ECT). RESERVED WORDS CAN BE ADDED OR DELETED
BY CHANGING THE PROGRAM DATA STATEMENTS AT THE END OF THE PROGRAM.
AS YOU ADD OR DELETE RESERVED WORDS KEEP THEM IN ALPHABETIC ORDER,
SINCE THE PROGRAM TABLES THEM AND DOES A BINARY SEARCH ON THE TABLE.
ALSO CHANGE THE FIRST DATA STATEMENT, THIS IS A COUNT OF THE NUMBER
OF RESERVED WORDS TO READ AND "DIM" TABLES.
YOU WILL SEE A NUMERIC VALUE AFTER EACH RESERVED WORD ON THE DATA
STATEMENTS. IF THE VALUE IS ZERO THE RESERVED WORD WILL BE RECOGNI-
ZED AS SUCH BUT ANY REFERENCES WILL BE IGNORED AND NOT PRINTED.
THERE ARE SEVERAL NUMERIC VALUES, AFTER THE RESERVED WORDS.
I STARTED TO GROUP THE WORDS ACCORDING TO TYPE AND FUNCTION (
I/O,BRANCH,STRING,FUNCTION..ECT) AND PROVIDE AND OPTION AS TO WHAT
FUNCTIONAL CLASS OF RESERVED WORDS WOULD BE X-REFERENCED. YOU MAY
IMPLEMENT THIS IF YOU DESIRE.
FOR EXAMPLE, IT WOULD BE NICE TO SEE A X-REFERENCE OF ONLY
LOGIC BRANCH VERBS (GOTO,GOSUB,CALL...ECT), THEN YOU COULD SEE
WHERE PROGRAM CONTROL WOULD BE TRANSFERED TO.
WILL PRINT A CROSS REFERENCE (ASCENDING ON VARIABLE NAME) OF ALL
USER DEFINED PROGRAM VARIABLES.
THIS WOULD BE GREAT FOR FINDING STATEMENTS THAT DEFINE OR MODIFY
A VARIABLE.
ANY TYPE OF BASIC EXPLICIT VARIABLE STATE ,SUCH AS "!" OR "#" OR
"%" OR "$" ARE IGNORED, ONLY THE VARIABLE NAME WHICH CONSISTS OF THE
CHARACTERS "A-Z","." AND "0-9" ARE CONSIDERED A UNIQUE NAME.
YOU MAY HAVE NOTICED THAT A VARIABLE NAME MAY BE DEFINED AS BEING
ONE OF SEVERAL VARIABLE TYPES. FOR EXAMPLE "A!" , "A#" , "A%", "A$"
, "A(" WHERE "A(" IS PART OF A "DIM", WOULD ALL BE RECOGNIZED TO THE
CROSS REFERENCE AS THE SAME VARIABLE, BUT DIFFERENT BY BASIC.
OH BY THE WAY, YOU MAY DEFINE A VARIABLE WITH A TERMINATING "."
TO ALSO MAKE IT UNIQUE. FOR EXAMPLE "SPACES" IS A RESERVED WORD,
BUT "SPACES." OR "SPACES.$" OR "SPACES.%" ARE PROCESSED BY BASIC
AS USER DEFINED VARIABLES. I JUST DISCOVERED IT AND THOUGHT IT
WAS A NEAT WAY TO GET AROUND SOME RESTRICTIONS.
ALSO YOU COULD HAVE THE FOLLOWING CODE AND IT WOULD WORK:
10 DIM A(10)
20 A=0
30 FOR A=1 TO 10
40 A(A)=A
50 NEXT A
60 END
CONFUSING BUT NEAT, HUH.
4). LINE NUMBER CROSS REFERENCE
---------------------------
WILL PRODUCE A (ASCENDING BY LINE NUMBER) CROSS REFERENCE,
LISTING ANY LINE NUMB╤¬ó!QüWAS REFERENCE BY ANOTHER LINE NUMBER
AND THE REFERENCING LINE NUMBER.
THIS LINE NUMBER CROSS REFERENCE TABLE IS ALSO USED IN THE
OPTION TO COMPRESS A PROGRAM. SO THAT WE DONT THROW AWAY "REMARK"
LINES THAT ARE BRANCHED TO.
YOU SHOULD USE THE LISTINGS PRODUCED TO CHANGE THE PROGRAM LOGIC
SUCH THAT IS DOES NOT BRANCH TO ANY NON-EXECUTABLE BASIC STATEMENTS.
THEY JUST SLOW THE PROGRAM DOWN AND MAKE IT HARD TO CHANGE LOGIC
SINCE REMOVING A REMARK MIGHT CAUSE AN ERROR, DURING RUN TIME OR
RENUMBERING.
I AM ALL FOR ALOT OF COMMENTS IN A PROGRAM, SINCE I HARDLY EVER
REMEMBER WHAT THE PROGRAM DOES, IF I PICK IT UP 6 MONTHS LATER,
OR I TRY TO MODIFY SOMEONE ELSES PROGRAM.
ALSO THE REMARKS TAKE UP PART OF THE "64K" THAT BASIC RUNS IN, SINCE
THEY ARE STORED EXACTLY AS SEEN ON THE SCREEN, NOT IN ANY TOKENIZED
FORM.
ALSO NOT BRANCHING TO "REMARKS" WILL ALLOW THE COMPRESS OPTION
TO REMOVE THAT STATEMENT FROM THE OUTPUT COMPRESSED FILE.
THIS RESULTS IN SAVINGS IN MEMORY WHEN THE PROGRAM IS STORED OR
LOADED, BUT PRIMARILY WHEN USING THE BASIC COMPILER.
THE BASIC COMPILER MAINTAINS A LINK LIST OF LINE NUMBERS. IF YOU
DO ANY TYPE OF "ON ERROR" CHECKING IN YOUR BASIC PROGRAM, EACH LINE
NUMBER , UNDER THESE CONDITIONS , RESULTS IN 4 OR MORE BYTES TO BE
USED IN THE ".OBJ" (OBJECT) FILE CREATED BY THE COMPILE. YOU COULD SEE
WHY COMPRESSING THE PRODUCION VERSION OF THE PROGRAM COULD RESULT IN
MEMORY AND SPEED SAVINGS.A LINK LIST MUST BE SEARCH AND IF YOUR PROGAM
WAS 500 LINES THEN (500 * (4+)) BYTES MUST BE USED JUST TO MAINTAIN
THE LINE NUMBER LIST.
*********************************************************************
MACHINE REQUIREMENTS: 64K
--------------------- BASIC
MONOCROME/COLOR DISPLAY
DISK DRIVE [REAL AND/OR VIRTUAL(RAM)]
MX-80 EPSON PRINTER (OPTIONAL)
RUNNING THE PROGRAM:
--------------------
TO RUN USING BASIC ---- INVOKE BASIC FROM DOS AND LOAD AND RUN
WHILE IN DOS KEY IN --- BASIC/F:3/C:0
IF PROGRAM COMPILED--- THEN JUST TYPE IN THE PROGRAM NAME YOU
GIVE IT WHEN YOU LINKED THE PROGRAM
ADDITIONAL COMMENTS:
--------------------
IF YOU COMPILE THIS PROGRAM YOU MUST CHANGE
ANY "DIM" STATEMENTS TO A FIXED VALUE, ALSO
DONT FORGET TO CHANGE THE ASSOCIATED "DIM"
VARIABLE NAME TO AGREE WITH THE FIXED VALUE
YOU ASSIGN TO THE ARRAY.
ALSO CHANGE THE STRING VARAIBLE "VER$" TO
A "C" TO INDICATE THE PROGRAM IS RUNNING AS
COMPILED, SINCE THE PROGRAM DOES POKE INTO
SOME BASIC AREAS ( TO CLEAR KEYBOARD BUFFER)
THAT ARE NOT THERE AFTER THE PROGRAM HAS BEEN
COMPILED. YOU ARE ASKING FOR TROUBLE IF YOU DON'T.
ALSO I PONDERED ADDING AN OPTION TO REMOVE
LINE NUMBERS FROM THE COMPRESSED PROGRAM, IF
THE COMPRESSED PROGRAM RUN TIME OPTION SELECTED.
THE BASIC COMPILER SAYS HE WILL OPTIMIZE
ACROSS BASIC CODE BETTER IF LINE NUMBERS
ARE NOT USED.
ALSO THE COMPILER WILL PROCESS A BASIC PROGRAM
CREATED BY ANY EDITOR. YOU DO NOT HAVE TO INCLUDE
LINE NUMBERS IN YOUR BASIC PROGRAM UNLESS YOU
WANT TO BRANCH TO A SPECIFIC LINE OF PROGRAM CODE.
I BELIEVE ALSO THE "LINE-NUMBERS" DON'T HAVE TO
BE CONSECUTIVE , JUST UNIQUE.
ALSO THE COMPILE INCLUDES AN "COPY-INCLUDE"
OPTION AT COMPILE TIME THAT LETS YOU COPY INTO
THE BASIC PROGRAM BEING READ OTHER COMMONLY
USED CODE AND SUBROUTINES.
IF YOU HAVE THE BASIC COMPILER YOU CAN READ
ABOUT THIS FURTHER.
**********************************************************************
IN CLOSING
----------
I WOULD APPRECIATE ANY COMMENTS AS TO ENHANCEMENTS, BUGS, OR GENERAL
USAGE. YOU MAY MAIL ME A LETTER OR LEAVE A MESSAGE ON WES MERCHANTS BBS
(703-560-0979) OR RICH SCHINNELL'S BBS (301-949-8848).
I HOPE THIS LITTLE CONTRIBUTION WILL HELP YOU.
BS
(703-560-0979) OR RICH SCHINNELL'S BBS (301-949-8848).